<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="author" content="wangzhichao">
	<title>选择要合并的申请单</title>
	<script LANGUAGE="javascript" src="../script/common.js" type="text/javascript"></script>
	<script LANGUAGE="javascript" type="text/javascript">
		var qt = {};
		var orderId ="";
		var type =0;
		//初始化数据
		function load(){
			orderId = getPara("newId");
			type = getPara("ct");
			var cOrg = Common.cOrg();
			searchForm.organization.value = cOrg.id;
			searchForm.cardType.value = type;
			searchForm.isPersent.value = getPara("isPersent");
			var requestOrgs = DWR.syncCall("storeQueryService.getRequestOrgs")
			
			Common.initDict(searchForm.requestCorp,requestOrgs,"全  部","id","name");	
			if(cOrg.orgLevel == Constants.ORG_LEVEL_HQ){
				searchForm.requestCorp.value = getPara("restrictedOrg");
				searchForm.requestCorp.disabled = true
			}
			
			Eui.initBeginDateInput("beginDateTd","起始申请日期","searchForm","startrequestDate","endrequestDate","_pastDate");
			Eui.initEndDateInput("endDateTd","结束申请日期","searchForm","startrequestDate","endrequestDate","date");
			createTable();
			qt.showTable();
		}
		//生成查询语句
		function createTable(){
			var columns = [];
				columns[0] = {type:"checkbox"};
				columns[1] = {render:nameFunc3};
			qt = new QueryTable("sel_req_order","searchForm","datalist",columns);
		}
		//数据处理方法
		function nameFunc3(v,r){
			return "<a href=# onclick=\"showDetail("+r[0]+","+r[6]+");return false;\">"+v+"</a>"
		}
		function showDetail(id,hasInfo){
			if(hasInfo==true){
				var v = openDialogFrame("/store/request_order_detail.html?id="+id,"被合并的申请单信息",610,750)
			}else{
				var v = openDialogFrame("/store/request_order_detail.html?id="+id,"被合并的申请单信息",300,600)
			}
		}
		//保存数据
		function onSave(){
			if(orderId){
				var ids = qt.getBoxValue();
				if(ids==null||ids==""){
					showInformation("请选择您要提交的数据");return;
				}
				ids=ids.split(",");
				DWR.call("cardRequestService.mergeCardRequestOrder",orderId,ids,function(){			
					dialogBackValue(orderId)
				},{blockScreen:true});
			}else{
				var ids = qt.getBoxValue(true);
				if(ids==null||ids==""){
					showInformation("请选择您要提交的数据");return;
				}
				var amount = 0;
				for(var i=0;i<ids.length;i++){
					amount += ids[i][4];
				}
				dialogBackValue(amount)
			}
		}
	</script>
</head>
<body onload="load()">
	<div id="listview" >	
			<!--查询条件form-->
			<div class="searchForm">
				<form id="searchForm" name="searchForm">
				<input type="hidden" name="id">
				<input type="hidden" name="cardType">
				<input type="hidden" name="organization">
				<input type="hidden" name="isPersent">
				<table cellSpacing=0 cellPadding=6 width="100%" border=0>
					<tr>
						<td><label>单&nbsp;据&nbsp;&nbsp;编&nbsp;号</label> <input type="text" name="requestid" onblur="checkV(this,'int')" maxlength=12></td>
						<td><label>申&nbsp;&nbsp;&nbsp;请&nbsp;&nbsp;&nbsp;方</label> <select name="requestCorp"><option></option></select></td>
					</tr>
					<tr>
						<td id="beginDateTd"></td>
						<td id="endDateTd"></td>
						<td><button type="button" onclick="qt.showTable();">查   询</button></td>
					</tr>
				</table>
				</form>
			</div>
				<!--查询结构列表-->
				<div id="datalist"></div>
			
		</div>
</body>
</html>